<include file="Public/head" />
<include file="Public/menu" />
<include file="Hotels/menu" />
<!-- 详情页 -->
<div class="indexBox">
    <style type="text/css">
        .picbox{
            display:inline-block;
            width:108px;
            height:108px;
            position:relative;
        }
        .pic{
            width:100px;
            height:100px;
            position:absolute;
            top:8px;
        }
        .delpic{
            position:absolute;
            left:92px;
        }
    </style>
    <script type="text/javascript">
        // 标签页
        $(function(){
            $(".idTabs").idTabs();
        });
        // ajax地区联动
        function getRegion(tagId, pid, defaultid){
            // var pid = arguments[1] ? arguments[1] : "";
            // var defaultid = arguments[2] ? arguments[2] : "";
            if(pid == ""){
                $("#"+tagId).html("<option value=''>请选择... </option>");
                return ;
            }
            $.post("{:U('Hotels/area')}",{id:pid},function(result){
                var _out="<option value=''>请选择...</option>";
                $.each(result,function(k,v){
                    if(v.id == defaultid){
                        _out += "<option value='"+v.id+"' selected='selected'>"+v.name+"</option>";
                    }
                    else{
                        _out += "<option value='"+v.id+"'>"+v.name+"</option>";
                    }
                });
                $("#"+tagId).html(_out);
            },'json');
        }
        $(function(){
            $("#province").change(function(){
                getRegion("city", $("#province").val(), "");
                $("#district").html("<option value=''>请选择... </option>");
            });
            $("#city").change(function(){
                getRegion("district", $("#city").val(), "");
            });
        });
        // 初始化地区联动
        getRegion("province", 1, "{$data.province}");
        getRegion("city", "{$data.province}", "{$data.city}");
        getRegion("district", "{$data.city}", "{$data.district}");
        // 图片删除
        function delPic(picId){
            if(picId == ""){
                return ;
            }
            $.post("{:U('Hotels/delPic')}", "id="+picId, function(result){
                if(result != 0){
                    getPic("{$data.id}");
                }
            }, "text");
        }
        function getPic(hotelId){
            var hotelId = arguments[0] ? arguments[0] : "";
            if(hotelId == ""){
                return ;
            }
            $.post("{:U('Hotels/getPic')}", "id="+hotelId, function(result){
                var _out = "";
                if(result.pics != 0){
                    $.each(result.pic, function(k,v){
                        _out += "<div class='picbox'>";
                        _out += "<img src='"+"__UPLOAD__/{$Think.CONTROLLER_NAME}/"+v.picture+"' class='pic' />";
                        _out += "<img src='__PUBLIC__/Admin/images/action_stop.png' class='delpic' picid='"+v.id+"' />";
                        _out += "</div>";
                    });
                }
                else{
                    _out = "还没有添加图片";
                }
                $("#pictd").html(_out);
                $("#pictd").attr("pics", result.pics);
            }, "json");
        }
        getPic("{$data.id}");
        $(function(){
            $("#pictd").delegate(".delpic","click",function(){
                delPic($(this).attr("picid"));
                getPic("{$data.id}");
            });
        });
    </script>
    <div class="idTabs">
        <ul class="tab">
            <li><a href="#main">添加/编辑酒店信息</a></li>
            <li><a href="#photo">添加/编辑酒店图片</a></li>
        </ul>
        <div class="items">
            <form action="{:U('Hotels/doEdit')}" method="post" enctype="multipart/form-data">
                <div id="main">
                    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                        <tbody>
                            <tr>
                                <th width="131">名称</th>
                                <th>内容</th>
                            </tr>
                            <tr>
                                <td align="right">酒店名称</td>
                                <td>
                                    <input type="text" name="name" value="{$data.name}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">地址</td>
                                <td>
                                    <select name="province" id="province"><option value=''>请选择... </option></select>省
                                    <select name="city" id="city"><option value=''>请选择... </option></select>市
                                    <select name="district" id="district"><option value=''>请选择... </option></select>区
                                </td>
                            </tr>
                            <tr>
                                <td align="right">详细地址</td>
                                <td>
                                    <input type="text" name="address" value="{$data.address}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">电话</td>
                                <td>
                                    <input type="text" name="tel" value="{$data.tel}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr>
                                <td align="right">景点</td>
                                <td>
                                    <select name="senic_id">
                                        <volist name="senic" id="v">
                                            <if condition="$v['id'] == $data['senic_id']">
                                                <option value="{$v.id}" selected="selected">{$v.name}</option>
                                            <else />
                                                <option value="{$v.id}">{$v.name}</option>
                                            </if>
                                        </volist>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">评分</td>
                                <td>
                                    <input type="text" name="points" value="{$data.points}" size="80" class="inpMain" />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input type="hidden" name="id" value="{$data.id}" id="hiddenid" />
                                    <input name="submit" class="btn" type="submit" value="保存" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div id="photo">
                    <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
                        <tbody>
                            <tr>
                                <th width="131">名称</th>
                                <th>内容</th>
                            </tr>
                            <tr id="pictr">
                                <td align="right">图片</td>
                                <td id="pictd" pics="0"></td>
                            </tr>
                            <tr>
                                <td align="right">上传</td>
                                <td>
                                    <input type="file" name="picture[]" multiple />
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" align="center">
                                    <input name="submit" class="btn" type="submit" value="上传" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </form>
        </div>
    </div>
</div>
<include file="Public/footer" />